package com.aipanda.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.hibernate.validator.constraints.Length;

/**
 * SEO类
 * 
 * @param type SEO类型
 * @param title 标题
 * @param keywords 关键词
 * @param description 描述
 * @author wanyuxiang
 * 
 */
@Entity
@Table(name = "aipanda_seo")
public class Seo extends BaseEntity {
	private static final long serialVersionUID = -3503657242384822672L;
	private Type type;
	private String title;
	private String keywords;
	private String description;

	/**
	 * SEO类型
	 * 
	 * @param index 首页
	 * @param productList 产品集合
	 * @param productSearch 产品搜索
	 * @param productContent 产品内容
	 * @param articleList 文章集合
	 * @param articleSearch 文章搜索
	 * @param articleContent 文章内容
	 * @param brandList 商标集合
	 * @param brandContent 商标内容
	 * @author wanyuxiang
	 * 
	 */
	public enum Type {
		index, productList, productSearch, productContent, articleList, articleSearch, articleContent, brandList, brandContent;
	}

	@Column(nullable = false, updatable = false, unique = true)
	public Type getType() {
		return this.type;
	}

	public void setType(Type type) {
		this.type = type;
	}

	@Length(max = 255)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Length(max = 255)
	public String getKeywords() {
		return this.keywords;
	}

	public void setKeywords(String keywords) {
		if (keywords != null)
			keywords = keywords.replaceAll("[,\\s]*,[,\\s]*", ",").replaceAll(
					"^,|,$", "");
		this.keywords = keywords;
	}

	@Length(max = 255)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
}
